#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Copyright (c) 2021, Jeff McBride
# Copyright (c) 2021-2022, Christopher Durand
#
# This file is part of the modm project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
# -----------------------------------------------------------------------------

def init(module):
    module.name = ":board:samd21-xplained-pro"
    module.description = "Microchip SAMD21 Xplained Pro"

def prepare(module, options):
    if not options[":target"].partname == "samd21j18a-au":
        return False

    module.depends(":debug", ":platform:gclk", ":platform:gpio", ":platform:core", ":platform:usb", ":platform:uart:3")
    return True

def build(env):
    env.outbasepath = "modm/src/modm/board"
    env.substitutions = {
        "with_logger": True,
        "with_assert": env.has_module(":architecture:assert")
    }
    env.template("../board.cpp.in", "board.cpp")
    env.copy('board.hpp')

    env.outbasepath = "modm/openocd/modm/board/"
    env.collect(":build:openocd.source", "board/atmel_samd21_xplained_pro.cfg")
